package scau.mis4.chanyulin.atm.domain;

import scau.mis4.chanyulin.atm.base.utils.TimeUtils;
import java.util.Date;

/**
 * Created by chanyulin on 2018/4/27.
 * 凭条实体类
 */
public class Receipt {

    // 凭条信息
    private String infomation;
    // 凭条生成时间
    private Date createTime;

    public Receipt(String infomation) {
        this.infomation = infomation;
        this.createTime = new Date();
    }

    /**
     * 取款/存款凭条构造器
     * @param account
     * @param money
     */
    public Receipt(Account account, int money) {
        this.createTime = new Date();
        String action = "取款";
        if (money < 0) {
            action = "存款";
            money = 0 - money;
        }
        this.infomation =
            "银行卡：" + account.getCardId() + "\n" +
            "用户名：" + account.getName() + "\n" +
            action + "金额：" + money + "\n" +
            "取款时间：" + TimeUtils.dateToLongStr(createTime) + "\n" +
            "当前余额：" + account.getBalance() + "\n";
    }

    public String getInfomation() {
        return infomation;
    }

    public void setInfomation(String infomation) {
        this.infomation = infomation;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

}
